
#pragma once

/********************************************************************************
MIT License

Copyright(c) 3dRudder 2017

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
********************************************************************************/


#define _3DRUDDER_SDK_STATIC
#include "3dRudderSDK.h"
#include "..\Common\SharedData.h"
#include "afxwin.h"
#include "afxcmn.h"
#include "OpenGlCtrl.h"


// C3dRudderUnleashedVRConfig dialog
class C3dRudderUnleashedVRConfig : public CDialogEx
{
// Construction
public:
	C3dRudderUnleashedVRConfig(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_3DRUDDER_UNLEASHED_VR_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	CSISharedData m_SharedData;
	CSharedMemory m_SharedMemory;
	CSharedMemory m_SharedMemoryDebug;
	ns3dRudder::Axis m_Axis;
	ns3dRudder::CSdk *m_pSdk;
	CString m_sSteamPath;
// Implementation
protected:
	HICON m_hIcon;
	void SendMatrixHmd();
	void RefreshController();
	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedCancel();
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedBtCurveX();
	afx_msg void OnBnClickedBtCurveY();
	afx_msg void OnBnClickedBtCurveZ();
	afx_msg void OnBnClickedBtCurveRz();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnBnClickedBtLoad();
	afx_msg void OnBnClickedBtSave();
	afx_msg void OnBnClickedCkActivateCtrls();
	afx_msg void OnBnClickedCkActivateVRLocomotion();
	afx_msg void OnBnClickedBtActivate();
	afx_msg void OnBnClickedBtReset();
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedBtCalibration();
	afx_msg void OnBnClickedBtDebug();
	afx_msg void OnEnChangeEdSpeedAx();
	afx_msg void OnEnChangeEdSpeedAy();
	afx_msg void OnEnChangeEdSpeedAz();
	afx_msg void OnEnChangeEdSpeedRz();
	afx_msg void OnEnChangeEdHeightOffset();
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnBnClickedCkSmoothMode();
	afx_msg void OnEnChangeEdSmoothAx();
	afx_msg void OnEnChangeEdSmoothAy();
	afx_msg void OnEnChangeEdSmoothAz();
	afx_msg void OnEnChangeEdSmoothRz();

	void UpdateSliderValue();
	void ManageActivateUI();
	void CheckActivate();
	void InitOpenVR();
	bool Load(wchar_t *pPath);


	CComboBox m_CbCtrl1;
	CComboBox m_CbCtrl2;
	BOOL m_bNonSymPitch;
	BOOL m_bActivateCtrls;
	BOOL m_bActivateVRLocomotion;
	CString m_sSpeedAxisX;
	CString m_sSpeedAxisY;
	CString m_sSpeedAxisZ;
	CString m_sSpeedRotateZ;
	CEdit m_EdSpeedAx;
	CEdit m_EdSpeedAy;
	CEdit m_EdSpeedAz;
	CEdit m_EdSpeedRz;
	float m_fDPIx;
	float m_fDPIy;
	CStatic m_StVal1;
	CStatic m_StVal2;
	CString m_sHeightOffset;
	CEdit m_EdHeightOffset;
	CButton m_CkUpDown;
	CButton m_BtReset;
	CComboBox m_CbDriver;
	BOOL m_bActivated;
	CButton m_BtActivate;
	CButton m_BtCalibration;
	CStatic m_StVal3;
	CStatic m_StVal4;
	CStatic m_StVal5;
	CStatic m_StVal6;
	CStatic m_StValX;
	CStatic m_StValY;
	CStatic m_StValZ;
	BOOL m_bCalibrateInUse;
	CButton m_BtCalibrateInUse;
	CButton m_BtActivateVRLocomotion;
	CButton m_BtActivateControllers;
	CComboBox m_CbLeftH;
	CComboBox m_CbLeftV;
	CComboBox m_CbLeftT;
	CComboBox m_CbRightH;
	CComboBox m_CbRightV;
	CComboBox m_CbRightT;
	CStatic m_StSpeedAx;
	CStatic m_StSpeedAy;
	CStatic m_StSpeedAz;
	CStatic m_StSpeedRz;
	CStatic m_StLCtrl;
	CStatic m_StLeftH;
	CStatic m_StLeftV;
	CStatic m_StLeftT;
	CStatic m_StRCtrl;
	CStatic m_StRightH;
	CStatic m_StRightV;
	CStatic m_StRightT;
	CButton m_BtDebug;
	CStatic m_StDebug;
	COpenGlCtrl m_St3D;
	CSliderCtrl m_SlSpeedAx;
	CSliderCtrl m_SlSpeedAy;
	CSliderCtrl m_SlSpeedAz;
	CSliderCtrl m_SlSpeedRz;
	CSliderCtrl m_SlHOffset;
	CSliderCtrl m_SlSmoothnessAx;
	CSliderCtrl m_SlSmoothnessAy;
	CSliderCtrl m_SlSmoothnessAz;
	CSliderCtrl m_SlSmoothnessRz;
	CString m_sSmoothnessAx;
	CString m_sSmoothnessAy;
	CString m_sSmoothnessAz;
	CString m_sSmoothnessRz;
	CEdit m_EdSmoothAx;
	CEdit m_EdSmoothAy;
	CEdit m_EdSmoothAz;
	CEdit m_EdSmoothRz;
	CStatic m_StSmotthAx;
	CStatic m_StSmotthAy;
	CStatic m_StSmotthAz;
	CStatic m_StSmotthRz;
	CButton m_BtSmoothMode;

	int m_MaxSpeedAx;
	int m_MaxSpeedAy;
	int m_MaxSpeedAz;
	int m_MaxSpeedRz;
	int m_nMaxHOffset;
	BOOL m_bSmoothMode;
	BOOL m_bDebug;

	BOOL m_bExitWait;
	CString m_sConfigLoaded;
};
